package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ClassifyMapper {


    /**
     * 分类分页查询
     */
    Long countCategory(CategoryPageQueryDTO categoryPageQueryDTO);

    List<Category> GetCategotyList(CategoryPageQueryDTO categoryPageQueryDTO, int start);


    /**
     * 删除分类
     *
     * @param id
     */
    @Delete("delete from category where id =#{id}")
    void shanchu(Integer id);

    @AutoFill(value = OperationType.UPDATE)
    void xiugai(Category category);

    /**
     * 启用禁用
     *
     * @param
     * @return
     */

    @Update("update category set status=#{status},update_time=#{updateTime},update_user=#{updateUser} where id =#{id}")
    @AutoFill(value = OperationType.UPDATE)
    void qi(Category category);


    /**
     * 新增
     *
     * @param
     * @return
     */
    @AutoFill(value = OperationType.INSERT)
    void add(Category category);

    @Select("select *from category where type=#{type}")
    ArrayList<Category> typeSearch(Integer type);

    ArrayList<Category> userTypeSearch(Integer type);
}
